File: /var/www/kevin-demo/wp-content/plugins/wpforms-sendinblue/src/Api/Client.php
<?php
namespace WPFormsSendinblue\Api;
/**
* Class Client creates connections between addon and the Sendinblue API.
*
* @since 1.0.0
*/
class Client {
/**
* Authentication HTTP header name for a tracker API.
*
* @since 1.0.0
*
* @var string
*/
const TRACKER_HEADER_AUTH_KEY = 'ma-key';
/**
* Authentication HTTP header name.
*
* @since 1.0.0
*
* @var string
*/
const HEADER_AUTH_KEY = 'api-key';
/**
* URL for the Sendinblue API.
*
* @since 1.0.0
*
* @var string
*/
const API_URL = 'https://api.sendinblue.com';
/**
* URL for the Tracker API.
*
* @since 1.0.0
*
* @var string
*/
const TRACKER_API_URL = 'https://in-automate.sendinblue.com/api';
/**
* URL prefix for the Sendinblue API.
*
* @since 1.0.0
*/
const API_VERSION_URL = '/v3';
/**
* URL prefix for the Tracker API.
*
* @since 1.0.0
*/
const TRACKER_API_VERSION_URL = '/v2';
/**
* Create a new connection.
*
* @since 1.0.0
*
* @param string $api_key API key.
*
* @return Connection
*/
public function new_connection( $api_key ) {
return new Connection(
new Http\Request(
$this->get_url(),
[
'headers' => [
self::HEADER_AUTH_KEY => $api_key,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
]
)
);
}
/**
* Create a new tracker connection.
*
* @since 1.0.0
*
* @param string $ma_key Marketing Automation key (the special key that you can get from account endpoint).
*
* @return Connection
*/
public function new_tracker_connection( $ma_key ) {
return new Connection(
new Http\Request(
$this->get_tracker_url(),
[
'headers' => [
self::TRACKER_HEADER_AUTH_KEY => $ma_key,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
]
)
);
}
/**
* Retrieve an API URL with an API version.
*
* @since 1.0.0
*
* @return string
*/
public function get_url() {
return rtrim( self::API_URL, '/' ) . self::API_VERSION_URL;
}
/**
* Retrieve an API URL with an API version.
*
* @since 1.0.0
*
* @return string
*/
public function get_tracker_url() {
return rtrim( self::TRACKER_API_URL, '/' ) . self::TRACKER_API_VERSION_URL;
}
}